package com.design.pattern.behavioral.strategy;

import java.util.HashMap;
import java.util.Map;

/**
 * description
 *
 * @author RenQiQiang 2019/03/15 10:09
 */
public class PromotionStrategyFactory {

    private static final PromotionStrategy DEFAULT_STRATEGY = new DefaultPromotionStrategy();
    private static Map<String, PromotionStrategy> PROMOTION_STRATEGY_MAP = new HashMap<>();

    static {
        PROMOTION_STRATEGY_MAP.put(PromotionkKey.LIJIAN, new LiJianPromotionStrategy());
        PROMOTION_STRATEGY_MAP.put(PromotionkKey.FANXIAN, new FanXianPromotionStrategy());
        PROMOTION_STRATEGY_MAP.put(PromotionkKey.MANJIAN, new ManJianPromotionStrategy());
    }

    private PromotionStrategyFactory(){

    }

    public static PromotionStrategy getPromotionStrategyFactory(String key){
        PromotionStrategy promotionStrategy = PROMOTION_STRATEGY_MAP.getOrDefault(key,DEFAULT_STRATEGY);
        return promotionStrategy;
    }

    private interface PromotionkKey{
        String LIJIAN = "LIJIAN";
        String FANXIAN = "FANXIAN";
        String MANJIAN = "MANJIAN";
    }
}
